package com.kantboot.business.gc.controller;

import com.kantboot.business.gc.domain.dto.BusGcGame18nDTO;
import com.kantboot.business.gc.domain.dto.BusGcGame18nSaveDTO;
import com.kantboot.business.gc.domain.dto.BusGcGameSearchDTO;
import com.kantboot.business.gc.domain.vo.BusGcGameVO;
import com.kantboot.business.gc.service.IBusGcGameI18nService;
import com.kantboot.business.gc.service.IBusGcGameService;
import com.kantboot.util.common.result.RestResult;
import com.kantboot.util.core.param.PageParam;
import com.kantboot.util.core.result.PageResult;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Slf4j
@RestController
@RequestMapping("/business/gc/game")
public class BusGcGameController {

    @Resource
    private IBusGcGameService service;

    @Resource
    private IBusGcGameI18nService i18nService;

    @RequestMapping("/getBodyList")
    public RestResult<List<BusGcGameVO>> getBodyList(@RequestBody BusGcGameSearchDTO param) {
        return RestResult.success(service.getBodyList(param),"getSuccess","获取成功");
    }

    @RequestMapping("/getBodyData")
    public RestResult<PageResult> getBodyData(@RequestBody PageParam<BusGcGameSearchDTO> param) {
        return RestResult.success(service.getBodyData(param), "getSuccess", "获取成功");
    }

    @RequestMapping("/getById")
    public RestResult<BusGcGameVO> getById(@RequestParam("id") Long id) {
        return RestResult.success(service.getById(id), "getSuccess", "获取成功");
    }

    /**
     * 获取Top12游戏
     */
    @RequestMapping("/getTop12")
    public RestResult<List<BusGcGameVO>> getTop12() {
        return RestResult.success(service.getTop12(), "getSuccess", "获取成功");
    }

    /**
     * 模糊搜索游戏
     */
    @RequestMapping("/search")
    public RestResult<PageResult> searchGame(@RequestBody PageParam<BusGcGameSearchDTO> pageParam) {
        return RestResult.success(service.searchGame(pageParam), "getSuccess", "获取成功");
    }

    /**
     * 新增点击数
     */
    @RequestMapping("/addClick")
    public RestResult addClick(@RequestParam("id") Long id) {

        return RestResult.success(service.addClick(id), "新增成功");
    }

    /**
     * 增加语言类型
     */
    @RequestMapping("/addLanguage")
    public RestResult addLanguage(@RequestBody BusGcGame18nSaveDTO saveDTO) {
        i18nService.addLanguage(saveDTO);
        return RestResult.success("addSuccess","添加成功");
    }

    /**
     * 批量删除语言类型
     */
    @RequestMapping("/deleteLanguage")
    public RestResult deleteLanguage(@RequestBody List<BusGcGame18nSaveDTO> busGcTypeI18nSaveDTOList) {
        i18nService.deleteLanguage(busGcTypeI18nSaveDTOList);
        return RestResult.success("deleteSuccess","删除成功");
    }

    /**
     * 获取不同类别id的语言列表
     */
    @RequestMapping("/getLanguageList")
    public RestResult<PageResult> getLanguageListByTypeId(@RequestBody PageParam<BusGcGame18nDTO> param) {
        return RestResult.success(i18nService.getLanguageListByTypeId(param), "getSuccess", "获取成功");
    }

}
